module.exports = (sql, params = null) => {
    const mysql = require("mysql");
    const conn = mysql.createConnection({
        host: "localhost",
        user: "root",
        password: "root",
        database: "test555",
    });
    conn.connect();
    return new Promise((reselove, reject) => {
        conn.query(sql, params, (err, data) => {
            err ? reject(err) : reselove(data);
        });
        conn.end();
    }).catch((err) => {
        console.log(err);
    });
};

// module.exports = (sql, params, callback) => {
//     const mysql = require("mysql");
//     const conn = mysql.createConnection({
//         host: "localhost",
//         port: "3306",
//         user: "root",
//         password: "root",
//         database: "test555",
//     });
//     conn.connect();
//     conn.query(sql, params, callback);
//     conn.end();
// };